package demo1;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.Banner.Mode;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@SpringBootApplication(exclude = { RedisAutoConfiguration.class })
@Configuration
public class UserApplication {
	// 通过Java配置来实例化Spring容器
	// AnnotationConfigApplicationContext context = new
	// AnnotationConfigApplicationContext(SpringConfig.class);

	// 在Spring容器中获取Bean对象
	@Autowired
	UserService userService;

	@RequestMapping("/hello")
	
	public String hello() {
		return userService.queryUserList().toString();
		//return "bbbbb";
	}

	@Bean // 通过该注解来表明是一个Bean对象，相当于xml中的<bean>
	public UserDAO getUserDAO() {
		return new UserDAO(); // 直接new对象做演示
	}

	public static void main(String[] args) {

		SpringApplication application = new SpringApplication(UserApplication.class);
		application.setBannerMode(Mode.OFF);
		application.run(args);
	}
}
